-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chat: brought back syntax highlighting for most common languages #5874
Conversation
… as dart or scss - Updated rehype-highlight to ^7.0.0 in orde to get rid of lowlight 2.9.0 and load only version 3.1.0 - Added dependency on highlight.js since we load these extra syntax languages and tslint complains if we don't add it
@sqs in #5232 you went from all to the common syntax bundle. I decided to give it a shot and I've added all of the languages that were part of the old "LANGUAGES" constant Lowlight COMMON brings: in total there are 53 languages supported. There was also a request for Delphi that I could add an import for as there is someone in the forum asking for it. Depending on how many people would need this, support for Delphi syntax could also be added. I believe that this repo could also forgo the loading of the common selection from Lowlight and opt to import exactly what it thinks it should import based on whatever analytics you guys have on what languages are requested with Cody Chat. Once you decide if the current crop I have made is what you want to support this should also be mentioned in the documentation so that the end users know which languages Cody Chat supports for syntax highlighting. |
In the future either an alternative library should be used or extra works need to be done to see if you can read the color scheme of the editor and see if there isn't something that matches. There is already an issue that mentions the difference in coloring from the chat to the actual editor color |
- As requested in review as it seems there were performance issues with rehype-highlight 7.0.0 as seen in pull request sourcegraph#5313
@vovakulikov @dominiccooney I am aware now that the build fails after pinning lowlight to version 2.9.0 since they made the common export the way I've imported from 3.0. |
… languages from highligh.js - This way we can trim the bundle even more by importing only languages that should be supported
vscode/package.json
Outdated
@@ -56,7 +56,14 @@ | |||
"version-bump:patch": "RELEASE_TYPE=patch ts-node-transpile-only ./scripts/version-bump.ts", | |||
"version-bump:dry-run": "RELEASE_TYPE=prerelease ts-node-transpile-only ./scripts/version-bump.ts" | |||
}, | |||
"categories": ["AI", "Chat", "Programming Languages", "Machine Learning", "Snippets", "Education"], | |||
"categories": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't choose todo this format. Every time I save package.json within vscode I get this autoformat and this time it slipped my guard when I removed lowlight pin.
I don't know how you guys do not get package.json to re-format, looking at the biome config package.json is not an ignored file
https://github.com/sourcegraph/cody/blob/main/biome.jsonc#L82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this arises because your IDE is formatting it with some different rule... if in VSCode, open that file, cmd-shift-P and Format Document with... and confirm that Biome is the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dominiccooney indeed I didn't have biome set as default which is a bit strange considering that the biome extension is installed and the biome config is within the Cody repo. At the very least VS Code should have given me the warning that biome isn't set as default for json files popup and ask me if I want to set it as default.
Nevertheless, I've modified the default so this shouldn't be a problem in the future.
I have removed lowlight dependency opting to import directly the languages from highlight.js which is what lowlight was doing anyway. the list of languages are: At this point it is up to you guys on which languages you want to support and which not, if you are concerned with bundle size and you have some analytics on what people use as the most common languages then by all means let me know and I can trim this list even further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
How does this affect the plugin size?
It would be great to have a test that quickly confirmed some colors appear for a few major and minor kinds of files in this list.
@dominiccooney I'll run the vite-analyzer and check. I am still waiting to hear from you guys on which syntaxes you think it actually make sense to support. Besides the 17 new ones loaded I question the usefulness of a bunch of languages that were previously loaded from the common bundle. If you can give me a list of things you know you want to have syntax support for I can modify the pull request to only load those. |
…r due to loading of such library
Patched this locally and tried it, it's great. I have pushed it here to run CI: #5953 |
@ichim-david regarding syntaxes to support, I don't have data about generated code languages handy, but here's the top 50 languages for autocomplete suggestions. Obviously some of these don't make sense, like we're not going to syntax highlight "txt" output. Regarding the existing languages being dubious, which ones specifically? I would be reticent to take a language away unless the highlighting quality is poor or it is super expensive for some reason. python |
…ild error due to loading of such library" This reverts commit 9e85405. Upon running pnpm install again in the root pnpm build no longer complained about the loading of the external library.
@dominiccooney you've asked about the bundle difference. For Cody web the syntaxes are saved and loaded within dist/index.js |
@dominiccooney to finish this logic I've looked at your list and found some languages that there are syntaxes available and some that aren't. Syntax not found Languages with support from highlight.js (https://github.com/highlightjs/highlight.js/tree/main/src/languages) EDIT: |
Authored by @ichim-david in #5874. This branch created to run CI. ## Test plan Ask chat to provide an example program for dart language. You should now see the dart snippets having syntax highlighting which started missing after the work done in this pull request: #5232 Example screenshot with the fix in action: ![dart-syntax](https://github.com/user-attachments/assets/78b0f19a-2c6c-4789-93d7-ef087eae7862) ## Changelog Chat: brought back syntax highlighting for most common languages --------- Co-authored-by: David Ichim <[email protected]>
Merged in #5953. Thank you for the contribution and apologies for the delay @ichim-david! |
Test plan
Ask chat to provide an example program for dart language.
You should now see the dart snippets having syntax highlighting which started missing after
the work done in this pull request:
#5232
Example screenshot with the fix in action:
Changelog
Chat: brought back syntax highlighting for most common languages